package com.google.project.server.entity;

import java.io.Serializable;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.project.shared.AssignTaskDTO;

@SuppressWarnings("serial")
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class AssignTask implements Serializable {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id;
	@Persistent
	private String taskId;
	@Persistent
	private String userId;
	@Persistent
	private String userCode;
	@Persistent
	private String userName;
	@Persistent
	private String specializeName;
	@Persistent
	private int experient;

	public AssignTask() {

	}

	public AssignTask(AssignTaskDTO data) {

		this.taskId = data.getTaskId();
		this.userId = data.getUserId();
		this.userCode = data.getUserCode();
		this.userName = data.getUserName();
		this.specializeName = data.getSpecializeName();
		this.experient = data.getExperient();
	}

	public void updateFromDTO(AssignTaskDTO data) {

		this.taskId = data.getTaskId();
		this.userId = data.getUserId();
		this.userCode = data.getUserCode();
		this.userName = data.getUserName();
		this.specializeName = data.getSpecializeName();
		this.experient = data.getExperient();
	}

	public AssignTaskDTO toDTO() {
		AssignTaskDTO data = new AssignTaskDTO();
		data.setId(id);
		data.setTaskId(taskId);
		data.setUserId(userId);
		data.setUserCode(userCode);
		data.setUserName(userName);
		data.setSpecializeName(specializeName);
		data.setExperient(experient);
		return data;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getTaskId() {
		return taskId;
	}

	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getSpecializeName() {
		return specializeName;
	}

	public void setSpecializeName(String specializeName) {
		this.specializeName = specializeName;
	}

	public int getExperient() {
		return experient;
	}

	public void setExperient(int experient) {
		this.experient = experient;
	}

}
